<template>
    <div class="login-index">
        <a id="to-home" href="https://tianzhongli.shop" target="_blank"
            >>>去官网</a
        >
        <a id="to-index" @click="$router.push('/')">>>回首页</a>
        <aside>
            <el-card>
                <!-- 侧内容 -->
                <section class="side" :class="{ active: useLoginStore.active }">
                    <el-card>
                        <div class="container">
                            <div class="code">
                                <img src="../../assets/images/gitee.png" />
                                <div class="code-msg">
                                    <strong>田中笠网上商城APP</strong>
                                    <span>扫码下载田中笠官方APP</span>
                                </div>
                            </div>
                            <div class="img">
                                <img
                                    src="https://img.tianzhongli.shop/i/2023/03/19/VCG211125808709.webp"
                                    alt="https://img.tianzhongli.shop/i/2023/03/19/VCG211125808709.webp"
                                />
                            </div>
                        </div>
                    </el-card>
                </section>
                <!-- 主内容 -->
                <router-link to="/" class="to-home">
                    <el-image
                        src="https://img.tianzhongli.shop/i/2023/03/16/tzl_logo.webp"
                    ></el-image>
                    <img
                        id="tzl_text"
                        src="../../assets/images/logo.jpg"
                        alt="田中笠logo"
                        class="logo"
                /></router-link>
                <!-- 切换面板 -->
                <transition name="scale" mode="out-in">
                    <div v-if="useLoginStore.active" class="login-section">
                        <Login />
                    </div>
                    <div v-else class="register-section">
                        <Register />
                    </div>
                </transition>

                <div class="login-button">
                    <el-switch
                        v-model="useLoginStore.active"
                        class="ml-2"
                        inline-prompt
                        style="
                            --el-switch-on-color: #e5a84b;
                            --el-switch-off-color: rgb(72, 135, 207);
                        "
                        active-text="登录"
                        inactive-text="注册"
                    />
                </div>
            </el-card>
        </aside>
        <div class="copyright">
            <span>© 2023 田中笠版权所有 豫ICP备2022028019号-1</span>
        </div>
    </div>
</template>

<script setup>
import { ref } from 'vue'
import Login from './components/login.vue'
import Register from './components/register.vue'
import { loginStore } from '@/stores/login'
const useLoginStore = loginStore()
</script>

<style lang="scss" scoped>
.login-index {
    height: 100vh;
    background: url(https://img.tianzhongli.shop/i/2023/03/18/天空-麦场.webp)
        no-repeat;
    overflow: hidden;
    background-size: cover;
    position: relative;
    aside {
        position: absolute;
        width: 400px;
        height: 450px;
        left: 60%;
        top: 10%;
        .el-card {
            opacity: 0.9;

            width: 100%;
            height: 100%;
            .side {
                position: absolute;
                width: 0px;
                height: 450px;
                top: 0px;
                right: 100%;
                border-radius: 20px;
                transition: all 0.3s ease;
                opacity: 0;
                z-index: -10;
                &.active {
                    width: 450px;
                    opacity: 1;
                    z-index: 99999;
                }
            }
            .login-section,
            .register-section {
                width: 360px;
                height: 300px;
                margin-top: 20px;
                display: flex;
                justify-content: center;
                align-items: center;
            }

            .login-button {
                z-index: 10;
                position: absolute;
                top: 10px;
                right: 10px;
            }
        }
    }
}
.to-home {
    display: block;
    width: 100px;
    height: 60px;
    .el-image {
        width: 100px;
        height: 60px;
    }
    .logo {
        position: absolute;
        width: 33px;
    }
}
.copyright {
    z-index: 99999;
    position: absolute;
    right: 0%;
    bottom: 0%;
    background-color: black;
    span {
        color: white;
        font-size: 12px;
        user-select: text;
    }
}
.container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    .code {
        display: flex;
        flex-direction: row;
        margin-top: 26px;
        margin-left: 70px;
        .code-msg {
            display: flex;
            flex-direction: column;
            margin-top: 20px;
            margin-left: 20px;
        }
        img {
            width: 80px;
            height: 80px;
        }
    }
    .img {
        position: relative;
        top: 40px;
        width: 450px;
        opacity: 1;
        img {
            transform: translateX(-20px);
        }
    }
}
#to-home {
    font-size: 18px;
    color: #d5ebe1;
    cursor: pointer;
    text-decoration: underline;
    margin-right: 20px;
}
#to-index {
    font-size: 18px;
    color: #d5ebe1;
    cursor: pointer;
    text-decoration: underline;
}

// 过渡动画
.scale-enter-active,
.scale-leave-active {
    transition: all 0.3s ease;
}

.scale-enter-from,
.scale-leave-to {
    opacity: 0;
    transform: scale(0.9);
}
</style>
